package com.lee.ssm.dao;

import com.lee.ssm.domain.Member;
import com.lee.ssm.domain.Orders;
import com.lee.ssm.domain.Product;
import org.apache.ibatis.annotations.*;

import java.util.List;


public interface IOrderDao {

    @Results(id = "orderProduct",
           value ={@Result(id=true,property = "id",column = "id"),
                   //如果名称相同，可以不写，但是主键必须写
                    @Result(property = "orderNum",column = "orderNum"),
                    @Result(property = "orderTime",column = "orderTime"),
                    @Result(property = "orderStatus",column = "orderStatus"),
                    @Result(property = "peopleCount",column = "peopleCount"),
                    @Result(property = "peopleCount",column = "peopleCount"),
                    @Result(property = "payType",column = "payType"),
                    @Result(property = "orderDesc",column = "orderDesc"),
                    @Result(property = "product", column = "productId",javaType = Product.class,one=@One(select="com.lee.ssm.dao.IProductDao.findById") )}
                )
    @Select("select * from orders")
    List<Orders> findAll();

    @Results(
            value ={@Result(id=true,property = "id",column = "id"),
                    @Result(property = "product", column = "productId",javaType = Product.class,one=@One(select="com.lee.ssm.dao.IProductDao.findById") ),
                    @Result(property = "member",column = "memberId",javaType = Member.class,one=@One(select = "com.lee.ssm.dao.IMemberDao.findById")),
                    @Result(property = "travellers",column = "id",javaType =java.util.List.class,many = @Many(select = "com.lee.ssm.dao.ITravellerDao.findByOrderId"))}
    )
    @Select("select * from orders where id=#{oderId}")
    Orders findById( String oderId);
}
